package models

import (
	"time"
)

const TableNamePaperQuestion = "paper_questions"

// PaperQuestion mapped from table <paper_questions>
type PaperQuestion struct {
	ID            int32     `gorm:"column:id;primaryKey" json:"id_pg"`
	PaperID       int32     `gorm:"column:paper_id;not null" json:"paper_id"`
	QuestionID    int32     `gorm:"column:question_id;not null" json:"question_id"`
	QuestionOrder int32     `gorm:"column:question_order;not null" json:"question_order"`
	Score         int32     `gorm:"column:score;type:INTEGER" json:"score"`
	CreatedAt     time.Time `gorm:"column:created_at;type:DATETIME" json:"created_at_pq"`

	// 与Question表的关联：通过QuestionID关联到Question表的ID
	Question Question `gorm:"foreignKey:QuestionID;references:ID" json:"question,omitempty"`
	// 与Paper表的关联：通过PaperID关联到Paper表的ID
	Paper Paper `gorm:"foreignKey:PaperID;references:ID" json:"paper,omitempty"`
}

// TableName PaperQuestion's table name
func (*PaperQuestion) TableName() string {
	return TableNamePaperQuestion
}
